package com.lixin.juc.countdownlatch;

import java.util.concurrent.CountDownLatch;

public class MainApplication {
    public static void main(String[] args) {
        CountDownLatch countDownLatch = new CountDownLatch(5);
        for (int i = 1; i <= 5; i++) {
            new Thread(() -> {
                System.out.println("线程" + Thread.currentThread().getName() + "执行完毕");
                countDownLatch.countDown();
            }, String.valueOf(i)).start();
        }
        try {
            countDownLatch.await();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("当5个线程执行完毕代码才会继续往下执行");
    }
}
